package com.gengzp.rpc.model.nacos.dto;

import java.io.Serial;
import java.io.Serializable;
import java.util.Map;

/**
 * @ClassName NacosServiceInstanceV1Dto
 * @Description nacos服务实例dto v1
 * @Author gengzp
 * @Date 2025/8/21 11:47
 */
public class NacosServiceInstanceV1Dto implements Serializable {

    @Serial
    private static final long serialVersionUID = 6848261761422029383L;

    /**
     * 实例的唯一标识
     * 格式通常为 {ip}#{port}#{cluster}#{serviceName}
     */
    private String instanceId;

    /**
     * 实例所在服务器的IP地址
     */
    private String ip;

    /**
     * 实例的端口号
     */
    private Integer port;

    /**
     * 实例的权重值（浮点型，默认1.0）
     * 权重越高，客户端选择该实例的概率越大
     */
    private Double weight;

    /**
     * 实例是否健康
     * true表示健康（通过Nacos健康检查），false表示不健康
     */
    private Boolean healthy;

    /**
     * 实例是否启用
     * true表示可用，即使健康，若为false也会被排除在服务发现结果外
     */
    private Boolean enabled;

    /**
     * 是否为临时实例
     * true：临时实例（依赖客户端心跳，断开连接后自动删除）
     * false：持久化实例（不依赖心跳，需手动删除）
     */
    private Boolean ephemeral;

    /**
     * 实例所属的集群名称
     */
    private String clusterName;

    /**
     * 实例所属的服务完整标识
     * 格式为 {groupName}@@{serviceName}
     */
    private String serviceName;

    /**
     * 实例的元数据（键值对集合）
     * 用于存储额外信息（如版本号、环境标签等）
     */
    private Map<String, String> metadata;

    /**
     * 实例发送心跳的间隔时间（毫秒），默认5000ms
     */
    private Long instanceHeartBeatInterval;

    /**
     * 实例ID的生成策略，如"simple"表示简单策略
     */
    private String instanceIdGenerator;

    /**
     * 心跳超时时间（毫秒），默认15000ms
     * 超过此时长未收到心跳，实例会被标记为不健康
     */
    private Long instanceHeartBeatTimeOut;

    /**
     * 实例被标记为不健康后，多久会被删除（毫秒），默认30000ms
     * 仅对临时实例有效
     */
    private Long ipDeleteTimeout;

    public String getInstanceId() {
        return instanceId;
    }

    public void setInstanceId(String instanceId) {
        this.instanceId = instanceId;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public Double getWeight() {
        return weight;
    }

    public void setWeight(Double weight) {
        this.weight = weight;
    }

    public Boolean getHealthy() {
        return healthy;
    }

    public void setHealthy(Boolean healthy) {
        this.healthy = healthy;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public Boolean getEphemeral() {
        return ephemeral;
    }

    public void setEphemeral(Boolean ephemeral) {
        this.ephemeral = ephemeral;
    }

    public String getClusterName() {
        return clusterName;
    }

    public void setClusterName(String clusterName) {
        this.clusterName = clusterName;
    }

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public Map<String, String> getMetadata() {
        return metadata;
    }

    public void setMetadata(Map<String, String> metadata) {
        this.metadata = metadata;
    }

    public Long getInstanceHeartBeatInterval() {
        return instanceHeartBeatInterval;
    }

    public void setInstanceHeartBeatInterval(Long instanceHeartBeatInterval) {
        this.instanceHeartBeatInterval = instanceHeartBeatInterval;
    }

    public String getInstanceIdGenerator() {
        return instanceIdGenerator;
    }

    public void setInstanceIdGenerator(String instanceIdGenerator) {
        this.instanceIdGenerator = instanceIdGenerator;
    }

    public Long getInstanceHeartBeatTimeOut() {
        return instanceHeartBeatTimeOut;
    }

    public void setInstanceHeartBeatTimeOut(Long instanceHeartBeatTimeOut) {
        this.instanceHeartBeatTimeOut = instanceHeartBeatTimeOut;
    }

    public Long getIpDeleteTimeout() {
        return ipDeleteTimeout;
    }

    public void setIpDeleteTimeout(Long ipDeleteTimeout) {
        this.ipDeleteTimeout = ipDeleteTimeout;
    }

}
